function PLandBuy()
{
RenderMap();
WindowStyle.drawWindow(8, 8, 250, 15);
Font.drawText(13, 13, "Welcome to Pangara Real Esate");

WindowStyle.drawWindow(8, 450, 150, 15);
Font.drawText(13, 455, "Gold: " + Player.gp + "Gp");

// execute the menu
  var REMenu = new Menu();
  REMenu.font         = Font;
  REMenu.window_style = WindowStyle;
  REMenu.arrow        = Arrow;
  REMenu.addItem("Buy",  BuyHouse);
  REMenu.addItem("Exit", WeaponShopMenu_Exit);
  REMenu.execute(6, 34, 272, 40);
}

function BuyHouse()
{
RenderMap();
WindowStyle.drawWindow(8, 8, 250, 15);
Font.drawText(13, 13, "Welcome to Pangara Real Esate");

WindowStyle.drawWindow(8, 450, 150, 15);
Font.drawText(13, 455, "Gold: " + Player.gp + "Gp");
// execute the menu
  var REMenu = new Menu();
  REMenu.font         = Font;
  REMenu.window_style = WindowStyle;
  REMenu.arrow        = Arrow;
  if (Phouse[0] == 1)
  {
  REMenu.addItem("Buy Chair at 2000gp",  BuyChair1);
  REMenu.addItem("Buy Table at 3000gp",  BuyTable1);
  REMenu.addItem("Buy Stove at 5000gp",  BuyStove1);
  REMenu.addItem("Buy Floor Mat at 4000gp",  BuyFloorM1);
  REMenu.addItem("Buy Floor Mat at 7000gp",  BuyFloorM2);
  REMenu.addItem("Buy Picture at 3500gp",  BuyPic1);
  REMenu.addItem("Buy Bed at 6000gp",  BuyBed1);
  REMenu.addItem("Buy Fireplace at 12000gp",  BuyFirePlace);
  REMenu.addItem("Buy Bookcase at 6000gp",  BuyBookcase);
  }
  else
  {
  REMenu.addItem("Buy House at 150,000gp",  BuyHouse2);
  }
  REMenu.addItem("Cancel", PLandBuy);
  REMenu.execute(6, 34, 272, 40);
}

function BuyHouse2()
{
  if (Player.gp < 150000)
  {
  Talk_Window("You don't have enough money!", Player.port);
  }
  else
  {
  Player.gp = Player.gp - 150000;
  Phouse[0] = 1;
  Talk_Window("Received Deed!", "blank.png");
  }
PLandBuy();
}

function BuyChair1()
{
BuyHouseStuff(2000, Phouse[1], 3, 1)
}
function BuyTable1()
{
BuyHouseStuff(3000, Phouse[2], 1, 2)
}
function BuyStove1()
{
BuyHouseStuff(5000, Phouse[3], 1, 3)
}
function BuyFloorM1()
{
  if (Phouse[5] == 1)
  {
  Talk_Window("Sold old mat for 5000 gp", "blank.png");
  Phouse[5] = 0;
  Player.gp = Player.gp + 5000;
  }
BuyHouseStuff(4000, Phouse[4], 1, 4)
}
function BuyFloorM2()
{
  if (Phouse[4] == 1)
  {
  Talk_Window("Sold old mat for 3000 gp", "blank.png");
  Phouse[4] = 0;
  Player.gp = Player.gp + 3000;
  }
BuyHouseStuff(7000, Phouse[5], 1, 5)
}
function BuyPic1()
{
BuyHouseStuff(3500, Phouse[6], 2, 6)
}
function BuyBed1()
{
BuyHouseStuff(6000, Phouse[7], 1, 7)
}
function BuyFirePlace()
{
BuyHouseStuff(12000, Phouse[8], 1, 8)
}
function BuyBookcase()
{
BuyHouseStuff(6000, Phouse[9], 1, 9)
}


function BuyHouseStuff(price, amount, mamount, k)
{
  if (amount >= mamount)
  {
  Talk_Window("Out of Stock", "blank.png");
  }
  else if (Player.gp < price)
  {
  Talk_Window("Not enough money!", "blank.png")
  }
  else
  {
  Phouse[k] = Phouse[k] + 1;
  Player.gp = Player.gp - price;
  }
PLandBuy();
}